from openpyxl import load_workbook
import glob
import os
import pandas as pd


def read_excel():
    d = None
    print(file)
    workbook_new = pd.ExcelFile(file)
    for i in workbook_new.sheet_names:
        d = pd.read_excel(file,sheet_name=i)
        for j in d.index:
            if "Product" in str(d.loc[j].values[0]):
                d = d.drop(labels=[c for c in range(0,j)],axis=0)
            else:
                for show_type in d.loc[j].values:
                    print(type(show_type),show_type)

            print("==" * 30)

    print(d.columns)
    print("==" * 20)
    d.columns = d.loc[3].values
    print(d.columns)
    # for j in d.index:
    #     print(d.loc[j].values)
# 封装 encapsulation
# 测试 test
# 生产 production

goal_mkdir = "d:/ccd_test/ccd"

for file in glob.glob('{}/**/*'.format(goal_mkdir),recursive=True):
    if os.path.isfile(file):
        # 提取名字分类
        # print(file)
        tab_name = os.path.basename(file).split(" ")
        # print(tab_name)
        # 开始处理
        if tab_name[0] == '111':
            #  封装
            continue
            print("11")
            if tab_name[1] == "111":
                pass
            if tab_name[1] == "222":
                pass
        if tab_name[0] == '222':
            if tab_name[1] == '111':
                pass
            if tab_name[1] == '222':
                pass
            if tab_name[1] == '333':
                pass

            # 测试
            pass
        if tab_name[0] == '333':
            # 生产

            read_excel()
            pass




